/**
 * Created by lenovo on 17-6-7.
 */
var express = require('express');
var router = express.Router();
var http = require('http');
var checkLogin = require('../middlewares/check').checkLogin;

router.get('/',checkLogin,function(req,res,next){
    http.get('http://localhost:3000/get_all_note',function(response){
        var rawData = '';
        response.setEncoding("utf-8");
        response.on("data", function(chunk){
            rawData += chunk;
        }).on('end',function(){
            console.log(JSON.parse(rawData).data)
            res.render('index',{
                title:'myblog',
                note_infos: JSON.parse(rawData).data,
                user: req.session.user
            })
        })
    });
});

module.exports = router;